package com.pudu.mydemo.utils;

import android.util.Log;

import java.util.ArrayList;

/**
 * Created by lgq on 2016/6/8.
 */
public class RegexpUtils {

    public static ArrayList<String> findString(String str) {

        ArrayList<String> datas = new ArrayList<String>();
        //  String str = "{CMD:SPD,V_L:-3.33,V_R:0.99}";
        String str2 = str.replace("{", "").replace("}", "");
        String[] split = str2.split(",");
        for (String s : split) {
            for (int i = 0; i < s.length(); i++) {
                if (s.substring(i, i + 1).equals(":")) {
                    String L = s.substring(0, i).trim();
                    String R = s.substring(i + 1, s.length()).trim();
                    datas.add(R);
                }
            }
        }
        return datas;
    }

    public static ArrayList<String> findStringLf(String str) {

        ArrayList<String> datas = new ArrayList<String>();
        //  String str = "{CMD:SPD,V_L:-3.33,V_R:0.99}";
        String str2 = str.replace("{", "").replace("}", "");
        String[] split = str2.split(",");
        for (String s : split) {
            for (int i = 0; i < s.length(); i++) {
                if (s.substring(i, i + 1).equals(":")) {
                    String L = s.substring(0, i).trim();
                    String R = s.substring(i + 1, s.length()).trim();
                    datas.add(L);
                }
            }
        }
        return datas;
    }
}
